Esempio n. 1
0
 /**
  * Imports an activity
  * @author Howard <*****@*****.**>
  * @static
  * @param string $activity
  * @param int $activity_id
  * @param array $params
  * @return mixed
  */
 public static function import($activity, $activity_id = 0, $params = false)
 {
     self::$_wpl_activity = $activity;
     $ex = explode(':', self::$_wpl_activity);
     self::$_wpl_activity_name = $ex[0];
     self::$_wpl_activity_layout = (isset($ex[1]) and trim($ex[1]) != '') ? $ex[1] : 'default';
     self::$_wpl_activity_file = (isset($ex[2]) and trim($ex[2]) != '') ? $ex[2] : 'main';
     $_wpl_activity_client = self::get_activity_client();
     $wpl_activity_path = 'views.' . $_wpl_activity_client . '.' . self::$_wpl_activity_name;
     $path = _wpl_import($wpl_activity_path . '.' . self::$_wpl_activity_file, true, true);
     /** check existation of an activity * */
     if (!wpl_file::exists($path)) {
         echo '<div>' . __("Activity not found!", WPL_TEXTDOMAIN) . '</div>';
         return;
     }
     /** set activity params * */
     $layout = $wpl_activity_path . '.tmpl.' . self::$_wpl_activity_layout;
     $params = self::get_params($activity_id, $params);
     $activity_class_name = 'wpl_activity_' . self::$_wpl_activity_file . '_' . self::$_wpl_activity_name;
     /** include the activity class if not exists * */
     if (!class_exists($activity_class_name)) {
         include $path;
     }
     $activity_object = new $activity_class_name();
     $activity_object->activity_id = $activity_id;
     $activity_object->start($layout, $params);
 }